package xin.infinite.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class JsonResult {

    private Integer status;         //200成功 201失败

    private String msg;             //提示信息

    private Object data;

    public static JsonResult success(){

        return new JsonResult(200,"成功",null);

    }

    public static JsonResult success(Object data){

        return new JsonResult(200,"成功",data);
    }

    public static JsonResult success(String msg,Object data){

        return new JsonResult(200,msg,data);
    }

    public static JsonResult fail(){

        return new JsonResult(201,"操作失败",null);
    }

    public static JsonResult fail(Exception e){

        return new JsonResult(201,e.getMessage(),null);
    }
}
